Determine source module of inLink

How do I determine the module name of an In-Link to an object? I've tried the dxl manual examples but they throw errors:

Object o = current

string srcModName

for srcModName in each o<-"Satisfies" do print srcModName "\n"

​-E- DXL: <Line:3> incorrect arguments for (<-)

-E- DXL: <Line:3> incorrect arguments for (do)

-E- DXL: <Line:3> incorrect arguments for function (each)

-I- DXL: All done. Errors reported: 3. Warnings reported: 0.


Aaron451 - Mon Apr 08 17:18:16 EDT 2019

Re: Determine source module of inLink
PekkaMakinen - Mon Apr 08 23:45:12 EDT 2019

That example in the DXL Referenece has an error in it, it needs a pair of parentheses

Object o = current 
string srcModName 
for srcModName in each (o <-"*") do print srcModName "\n"

Generally you can get the source module of a link by using the "source" function: 

Object o = current 
LinkRef lref 
ModName_ srcModRef 
for lref in o<-"*" do {
    srcModRef = source lref
    read(fullName(srcModRef), true)
} 

Re: Determine source module of inLink
Aaron451 - Tue Apr 09 09:30:33 EDT 2019

PekkaMakinen - Mon Apr 08 23:45:12 EDT 2019

That example in the DXL Referenece has an error in it, it needs a pair of parentheses

Object o = current 
string srcModName 
for srcModName in each (o <-"*") do print srcModName "\n"

Generally you can get the source module of a link by using the "source" function: 

Object o = current 
LinkRef lref 
ModName_ srcModRef 
for lref in o<-"*" do {
    srcModRef = source lref
    read(fullName(srcModRef), true)
} 

NICE!! Can't thank you enough. I've been dancing around this problem for years!

I added a couple comments and printing of module name to help me remember how to do this. For my particular use I just need to check the module name. I use it in a simple DXL filter. Why the link wizard doesn't give you the option to select a specific module to display I don't know (only a link module).

So to just get the module names of all inLinks:

Object o = current
string srcModName
for srcModName in each (o<-"*") do print srcModName "\n"

to open each module too:

// this finds, prints and opens the source module of any inLink to the current object
Object o = current 
LinkRef lref 
ModName_ srcModRef 
for lref in o<-"*" do {
    srcModRef = source lref
    read(fullName(srcModRef), true)
print name srcModRef "\n"
// this line will give the full path starting at the project folder
// print fullName(srcModRef) "\n"
}

 

Ultimately what I wanted to do was modify an attribute DXL script do display only links from a specific module. Kink of ugly but it works:

// loop until we find the module name and do something (or NOT)
Object o = current
string srcModName
for srcModName in each (o<-"*") do {
   if (srcModName == "<Name>") {
      print srcModName "\n"
      break
   }
}

if (srcModName == "<Name>") {
      print "Do some work here\n"
} else {
      print "Do nothing\n"
}

Re: Determine source module of inLink
llandale - Tue Apr 09 14:06:30 EDT 2019

If I recall that srcModName loop only returns the base-name of the module and is a residual artifact from way back in DOORS v4 days; where there were no folders and so modules needed no "path" information.

Bad advised that you cannot see an incoming "Link" unless the source module is already open; thus the use of using incoming "LinkRef"s where you cannot see the source object but  can see the source ModuleRef.

-Louie